import React from 'react';
import { connect } from 'dva';
import { Tabs, Icon } from 'antd';
import CommonList from '../../routes/commonList/commonList'; /* 公共列表 */
import CommonClassify from '../commonClassify/commonClassify'; /* 公共分类 */
import CustomerInfo from '../basicInfoSetting/customerInfo/customerInfo'; /* 客户信息 */
import Materiel from '../basicInfoSetting/materiel/materiel'; /* 物料信息 */
import Employee from '../basicInfoSetting/employee/employee'; /* 职员信息 */
import PrintInfo from '../basicInfoSetting/printInfo/printInfo'; /* 印件信息 */
import SystemSetting from '../basicInfoSetting/systemSetting/systemSetting'; /* 印件信息 */
import JurAllot from '../basicInfoSetting/jurisdictionAllot/jurisdictionAllot'; /* 权限分配 */
import SupplyInfo from '../basicInfoSetting/supplyInfo/supplyInfo'; /* 权限分配 */
import TeamInfo from '../basicInfoSetting/teamInfo/teamInfo'; /* 班组信息 */
import ProcessInfo from '../basicInfoSetting/processInfo/processInfo'; /* 工序信息 */
import MachineInfo from '../basicInfoSetting/machineInfo/machineInfo'; /* 设备信息 */
import SftLoginInfo from '../basicInfoSetting/sftLoginInfo/sftLoginInfo'; /* 用户管理 */
import SisFormula from '../basicInfoSetting/sisFormula/sisFormula'; /* 计算方案 */
import Commonstyle from '../basicInfoSetting/commonStyle/commonStyle'; /* 常用规格 */
import PaymentInfo from '../basicInfoSetting/paymentInfo/paymentInfo'; /* 付款条件 */
import CheckModel from '../basicInfoSetting/checkModel/checkModel'; /* 审核模板 */
import CheckPhase from '../basicInfoSetting/checkPhase/checkPhase'; /* 审核阶段 */
import SalesOrder from '../salesManage/salesOrder/salesOrder'; /* 销售订单 */
import SalesOrderSticker from '../salesManage/salesOrderSticker/salesOrderSticker'; /* 销售订单(不干胶) */
import SalesCheckMaster from '../salesManage/salesCheckMaster/salesCheckMaster'; /* 设定单据->销售对账 */
import DeliverNotify from '../salesManage/deliverNotify/deliverNotify'; /* 送货通知单 */
import DeliverGoods from '../salesManage/deliverGoods/deliverGoods'; /* 送货单 */
import RejectGoods from '../salesManage/rejectGoods/rejectGoods'; /* 退货单 */
import SalesCheck from '../salesManage/salesCheck/salesCheck'; /* 销售对账 */
import SalesInvoice from '../salesManage/salesInvoice/salesInvoice'; /* 销售发票 */
import SendCar from '../salesManage/sendCar/sendCar'; /* 派车单 */
import QualityAbnormal from '../salesManage/qualityAbnormal/qualityAbnormal'; /* 销售品质异常 */
import PurchaseApply from '../purchaseManage/purchaseApply/purchaseApply'; /* 采购申请 */
import PurchaseOrder from '../purchaseManage/purchaseOrder/purchaseOrder'; /* 采购订单 */
import PurchaseInstore from '../purchaseManage/purchaseInstore/purchaseInstore'; /* 采购入库 */
import PurchaseCheck from '../purchaseManage/purchaseCheck/purchaseCheck'; /* 采购对账 */
import PurchaseReject from '../purchaseManage/purchaseReject/purchaseReject'; /* 采购退货 */
import ProductionMaterials from '../materialsStock/productionMaterials/productionMaterials'; /* 生产补料 */
import MaterialsAdjust from '../materialsStock/materialsAdjust/materialsAdjust'; /* 生产调拨 */
import MaterialsInventoryAdjust from '../materialsStock/materialsInventoryAdjust/materialsInventoryAdjust'; /* 材料库存调整 */
import MaterialsCheck from '../materialsStock/materialsCheck/materialsCheck'; /* 材料盘点 */
import ProductInstore from '../productionInentory/productInstore/productInstore'; /* 成品入库 */
import AccountTransfer from '../accountsManage/accountTransfer/accountTransfer'; /* 财务转账 */
import CahReceipt from '../accountsManage/cahReceipt/cahReceipt'; /* 收款单 */
import CahPayment from '../accountsManage/cahPayment/cahPayment'; /* 付款单 */
import OutsideProcess from '../outsourceManage/outsideProcess/outsideProcess'; /* 发外加工（工序） */
import OutsideInstore from '../outsourceManage/outsideInstore/outsideInstore'; /* 发外加工确认（工序） */
import PurchaseChecking from '../outsourceManage/purchaseChecking/purchaseChecking'; /* 发外对账 */
import MftQualityAccident from '../mftQualityAccident/mftQualityAccident/mftQualityAccident'; /* 质量报告 */
import CahfinancialAdjust from '../accountsManage/cahfinancialAdjust/cahfinancialAdjust'; /* 财务调整 */
import SisProcessClassify from '../basicInfoSetting/sisProcessClassify/sisProcessClassify'; /* 工序分类 */
import ProductCheckMaster from '../productionInentory/productCheckMaster/productCheckMaster'; /* 成品盘点 */
import ProductAdjustMaster from '../productionInentory/productAdjustMaster/productAdjustMaster'; /* 成品调拨 */
import ProductStoreAdjust from '../productionInentory/productStoreAdjust/productStoreAdjust'; /* 成品库存调整 */
import WorkOrder from '../workOrder/workOrder/workOrder'; /* 生产施工单 */
import WorkOrderNew from '../manufacture/workOrder/workOrder'; /* 生产施工单 */
import ProcessCard from '../workOrder/processcard/processcard'; /* 产品工艺卡 */
import MftProductionReportMaster from '../mftProductionReportMaster/mftProductionReportMaster/mftProductionReportMaster'; /* 产量上报 */
import ProductClassify from '../basicInfoSetting/productClassify/productClassify'; /* 印件分类信息 */
import IndexCenter from '../indexCenter/indexCenter'; /* 首页 */
import TabComponent from '../../components/Tab/TabComponent';
import styles from '../../index.less';
import CommonBill from '../common/commonBill'; /* 通用单据页 */
import CommonChar from '../commonChar/commonChar'; /* 通用图表页 */
import ProductionPlan from '../productionPlan/productionPlan'; /* 生产排程 */
import EleteamInfo from '../common/eleteamInfo'; /* 班组信息页 新 */
import SisFormulaInfo from '../basicInfoSetting/sisFormula/sisFormulaInfo';
import EleMachineInfo from '../basicInfoSetting/machineInfo/eleMachineInfo'; /* 设备信息 */
import SystemPermissionInfo from '../basicInfoSetting/systemPermission/systemPermissionInfo'; /* 设备信息 */
import ImportDataInfo from '../importData/importData'; /* 设备信息 */
import PaymentTermsInfo from '../basicInfoSetting/paymentInfo/paymentInfoTerms';
import ProductionReport from '../basicInfoSetting/productReport/productReport'; /* 产量上报 */

/* 计算方案 */
const { TabPane } = Tabs;

function Tab({ dispatch, app }) {
  const { panes } = app;
  let paneType = '';
  const tabpanes = panes.map((pane) => {
    let content = '';
    if (pane.route === '/commonList') {
      content = <CommonList />;
    } else if (pane.route === '/commonClassify') {
      content = <CommonClassify />;
    } else if (pane.route === '/elecustomer') {
      content = <CustomerInfo />;
    } else if (pane.route === '/eleemployee') {
      content = <Employee />;
    } else if (pane.route === '/elematerials') {
      content = <Materiel />;
    } else if (pane.route === '/eleproduct') {
      content = <PrintInfo />;
    } else if (pane.route === '/syssystemsettings') {
      content = <SystemSetting />;
    } else if (pane.route === '/jurisdictionAllot') {
      content = <JurAllot />;
    } else if (pane.route === '/elesupply') {
      content = <SupplyInfo />;
    } else if (pane.route === '/eleteam') {
      content = <TeamInfo />;
    } else if (pane.route === '/eleprocess') {
      content = <ProcessInfo />;
    } else if (pane.route === '/elemachine') {
      content = <MachineInfo />;
    } else if (pane.route === '/elecheckmodel') {
      content = <CheckModel />;
    } else if (pane.route === '/sischeckphase') {
      content = <CheckPhase />;
    } else if (pane.route === '/sftlogininfo') {
      content = <SftLoginInfo />;
    } else if (pane.route === '/sisformula') {
      content = <SisFormula />;
    } else if (pane.route === '/salsalesordermaster') {
      content = <SalesOrder />;
    } else if (pane.route === '/salesOrderSticker') {
      content = <SalesOrderSticker />;
    } else if (pane.route === '/salescheckingmaster') {
      content = <SalesCheckMaster />;
    } else if (pane.route === '/deliverNotify') {
      content = <DeliverNotify />;
    } else if (pane.route === '/saldelivergoodsmaster') {
      content = <DeliverGoods />;
    } else if (pane.route === '/salrejectgoodsmaster') {
      content = <RejectGoods />;
    } else if (pane.route === '/salsalescheckingmaster') {
      content = <SalesCheck />;
    } else if (pane.route === '/salesInvoice') {
      content = <SalesInvoice />;
    } else if (pane.route === '/sendCar') {
      content = <SendCar />;
    } else if (pane.route === '/qualityAbnormal') {
      content = <QualityAbnormal />;
    } else if (pane.route === '/siscommonstyle') {
      content = <Commonstyle />;
    } else if (pane.route === '/sispayment') {
      content = <PaymentInfo />;
    } else if (pane.route === '/purpurchaseapplymaster') {
      content = <PurchaseApply />;
    } else if (pane.route === '/purpurchaseordermaster') {
      content = <PurchaseOrder />;
    } else if (pane.route === '/purpurchaseinstoremaster') {
      content = <PurchaseInstore />;
    } else if (pane.route === '/purpurchasecheckingmaster') {
      content = <PurchaseCheck />;
    } else if (pane.route === '/purpurchaserejectmaster') {
      content = <PurchaseReject />;
    } else if (pane.route === '/mitproductionmaterialsmaster') {
      content = <ProductionMaterials />;
    } else if (pane.route === '/mitmaterialsadjustmaster') {
      content = <MaterialsAdjust />;
    } else if (pane.route === '/mitmaterialsstoreadjustmentmaster') {
      content = <MaterialsInventoryAdjust />;
    } else if (pane.route === '/mitmaterialscheckmaster') {
      content = <MaterialsCheck />;
    } else if (pane.route === '/pitproductinstoremaster') {
      content = <ProductInstore />;
    } else if (pane.route === '/cahfinancialtransfer') {
      content = <AccountTransfer />;
    } else if (pane.route === '/cahreceiptmaster') {
      content = <CahReceipt />;
    } else if (pane.route === '/cahpaymentmaster') {
      content = <CahPayment />;
    } else if (pane.route === '/opsoutsideprocessmaster') {
      content = <OutsideProcess />;
    } else if (pane.route === '/opsoutsideinstoremaster') {
      content = <OutsideInstore />;
    } else if (pane.route === '/opsoutsidecheckingmaster') {
      content = <PurchaseChecking />;
    } else if (pane.route === '/mftqualityaccident') {
      content = <MftQualityAccident />;
    } else if (pane.route === '/cahfinancialadjust') {
      content = <CahfinancialAdjust />;
    } else if (pane.route === '/sisprocessclassify') {
      content = <SisProcessClassify />;
    } else if (pane.route === '/pitproductcheckmaster') {
      content = <ProductCheckMaster />;
    } else if (pane.route === '/pitproductadjustmaster') {
      content = <ProductAdjustMaster />;
    } else if (pane.route === '/pitproductstoreadjustmentmaster') {
      content = <ProductStoreAdjust />;
    } else if (pane.route === '/workOrder') {
      content = <WorkOrder />;
    } else if (pane.route === '/processcard') {
      content = <ProcessCard />;
    } else if (pane.route === '/mftproductionreportmaster') {
      content = <MftProductionReportMaster />;
    } else if (pane.route === '/sisproductclassify') {
      content = <ProductClassify />;
    } else if (pane.route === '/commonBill') {
      content = <CommonBill />;
    } else if (pane.route === '/workOrderNew') {
      content = <WorkOrderNew />;
    } else if (pane.route === '/productionPlan') {
      content = <ProductionPlan />;
    } else if (pane.route === '/commonChar') {
      content = <CommonChar />;
    } else if (pane.route === '/eleteamInfo') {
      content = <EleteamInfo />;
    } else if (pane.route === '/sisformulaInfo') {
      content = <SisFormulaInfo />;
    } else if (pane.route === '/elemachineInfo') {
      content = <EleMachineInfo />;
    } else if (pane.route === '/systemPermission') {
      content = <SystemPermissionInfo />;
    } else if (pane.route === '/importData') {
      content = <ImportDataInfo />;
    } else if (pane.route === '/sispaymentTerms') {
      content = <PaymentTermsInfo />;
    } else if (pane.route === '/productionReport') {
      content = <ProductionReport />;
    } else {
      content = <IndexCenter />;
    }


    if (pane.paneType) {
      paneType = <span><Icon type={pane.paneType} />{pane.title}</span>;
    } else {
      paneType = <span>{pane.title}</span>;
    }
    return (
      <TabPane tab={paneType} key={pane.key} style={{ minHeight: 510, fontSize: 13 }} className={styles.tabPane}>
        {content}
      </TabPane>
    );
  });
  const totalProps = {
    tabpanes,
    app,
    onSaveCurrentPane: saveCurrentPane,
    onRemove: removePane,
  };

  function saveCurrentPane(currentPane) {
    dispatch({ type: 'app/saveCurrentPane', payload: { currentPane } });
  }

  function removePane(changePanes, currentPane) {
    dispatch({ type: 'app/removePane', payload: { changePanes, currentPane } });
  }

  return (
    <div >
      <TabComponent {...totalProps} />
    </div>
  );
}

export default connect(({ app }) => ({ app }))(Tab);
